home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Tool Chest / !Interfaces / Universal Interfaces 2.0a1 / CIncludes / Events.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-07-17  |  6.9 KB  |  242 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        Events.h
  3.  
  4.      Copyright:    © 1984-1994 by Apple Computer, Inc.
  5.                  All rights reserved.
  6.  
  7.      Version:    Universal Interfaces 2.0a1.  ETO #15, MPW prerelease.  Sunday, July 17, 1994. 
  8.  
  9.      Bugs?:        If you find a problem with this file, send the file and version
  10.                  information (from above) and the problem description to:
  11.  
  12.                      Internet:    apple.bugs@applelink.apple.com
  13.                      AppleLink:    APPLE.BUGS
  14.  
  15. */
  16.  
  17. #ifndef __EVENTS__
  18. #define __EVENTS__
  19.  
  20.  
  21. #ifndef __TYPES__
  22. #include <Types.h>
  23. #endif
  24. /*    #include <ConditionalMacros.h>                                */
  25.  
  26. #ifndef __QUICKDRAW__
  27. #include <Quickdraw.h>
  28. #endif
  29. /*    #include <MixedMode.h>                                        */
  30. /*    #include <QuickdrawText.h>                                    */
  31.  
  32. #ifndef __OSUTILS__
  33. #include <OSUtils.h>
  34. #endif
  35.  
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39.  
  40. #if GENERATINGPOWERPC
  41. #pragma options align=mac68k
  42. #endif
  43.  
  44. #ifdef __CFM68K__
  45. #pragma lib_export on
  46. #endif
  47.  
  48.  
  49. enum {
  50.     nullEvent                    = 0,
  51.     mouseDown                    = 1,
  52.     mouseUp                        = 2,
  53.     keyDown                        = 3,
  54.     keyUp                        = 4,
  55.     autoKey                        = 5,
  56.     updateEvt                    = 6,
  57.     diskEvt                        = 7,
  58.     activateEvt                    = 8,
  59.     osEvt                        = 15,
  60. /* event mask equates */
  61.     mDownMask                    = 0x0002,                        /* mouse button pressed */
  62.     mUpMask                        = 0x0004,                        /* mouse button released */
  63.     keyDownMask                    = 0x0008,                        /* key pressed */
  64.     keyUpMask                    = 0x0010,                        /* key released */
  65.     autoKeyMask                    = 0x0020,                        /* key repeatedly held down */
  66.     updateMask                    = 0x0040,                        /* window needs updating */
  67.     diskMask                    = 0x0080,                        /* disk inserted */
  68.     activMask                    = 0x0100,                        /* activate/deactivate window */
  69.     highLevelEventMask            = 0x0400,                        /* high-level events (includes AppleEvents) */
  70.     osMask                        = 0x8000                        /* operating system events (suspend, resume) */
  71. };
  72.  
  73. enum {
  74.     everyEvent                    = 0xFFFFFFFFL,
  75. /* event message equates */
  76.     charCodeMask                = 0x000000FF,
  77.     keyCodeMask                    = 0x0000FF00,
  78.     adbAddrMask                    = 0x00FF0000,
  79.     osEvtMessageMask            = 0xFF000000L,
  80. /* OS event messages.  Event (sub)code is in the high byte of the message field. */
  81.     mouseMovedMessage            = 0x00FA,
  82.     suspendResumeMessage        = 0x0001,
  83.     resumeFlag                    = 1,                            /* Bit 0 of message indicates resume vs suspend */
  84.     convertClipboardFlag        = 2,                            /* Bit 1 in resume message indicates clipboard change */
  85. /* modifiers */
  86.     activeFlag                    = 0x0001,                        /* Bit 0 of modifiers for activateEvt and mouseDown events */
  87.     btnState                    = 0x0080,                        /* Bit 7 of low byte is mouse button state */
  88.     cmdKey                        = 0x0100,                        /* Bit 0 of high byte */
  89.     shiftKey                    = 0x0200,                        /* Bit 1 of high byte */
  90.     alphaLock                    = 0x0400,                        /* Bit 2 of high byte */
  91.     optionKey                    = 0x0800,                        /* Bit 3 of high byte */
  92.     controlKey                    = 0x1000,                        /* Bit 4 of high byte */
  93. /* obsolete equates */
  94.     networkEvt                    = 10,
  95.     driverEvt                    = 11,
  96.     app1Evt                        = 12,
  97.     app2Evt                        = 13
  98. };
  99.  
  100. enum {
  101.     app3Evt                        = 14,
  102.     app4Evt                        = 15,
  103.     networkMask                    = 0x0400,
  104.     driverMask                    = 0x0800,
  105.     app1Mask                    = 0x1000,
  106.     app2Mask                    = 0x2000,
  107.     app3Mask                    = 0x4000,
  108.     app4Mask                    = 0x8000
  109. };
  110.  
  111. struct EventRecord {
  112.     short                            what;
  113.     long                            message;
  114.     long                            when;
  115.     Point                            where;
  116.     short                            modifiers;
  117. };
  118. typedef struct EventRecord EventRecord;
  119.  
  120. typedef long KeyMap[4];
  121.  
  122. struct EvQEl {
  123.     QElemPtr                        qLink;
  124.     short                            qType;
  125.     short                            evtQWhat;                    /* this part is identical to the EventRecord as... */
  126.     long                            evtQMessage;                /* defined in ToolIntf */
  127.     long                            evtQWhen;
  128.     Point                            evtQWhere;
  129.     short                            evtQModifiers;
  130. };
  131. typedef struct EvQEl EvQEl;
  132.  
  133. typedef EvQEl *EvQElPtr;
  134.  
  135. typedef void (*GetNextEventFilterProcPtr)(EventRecord *theEvent, Boolean *result);
  136.  
  137. #if GENERATINGCFM
  138. typedef UniversalProcPtr GetNextEventFilterUPP;
  139. #else
  140. typedef GetNextEventFilterProcPtr GetNextEventFilterUPP;
  141. #endif
  142.  
  143. enum {
  144.     uppGetNextEventFilterProcInfo = SPECIAL_CASE_PROCINFO( kSpecialCaseGNEFilterProc )
  145. };
  146.  
  147. #if GENERATINGCFM
  148. #define NewGetNextEventFilterProc(userRoutine)        \
  149.         (GetNextEventFilterUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppGetNextEventFilterProcInfo, GetCurrentArchitecture())
  150. #else
  151. #define NewGetNextEventFilterProc(userRoutine)        \
  152.         ((GetNextEventFilterUPP) (userRoutine))
  153. #endif
  154.  
  155. #if GENERATINGCFM
  156. #define CallGetNextEventFilterProc(userRoutine, theEvent, result)        \
  157.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppGetNextEventFilterProcInfo, (theEvent), (result))
  158. #else
  159. /* (*GetNextEventFilterProcPtr) cannot be called from a high-level language without the Mixed Mode Manager */
  160. #endif
  161.  
  162. typedef GetNextEventFilterUPP GNEFilterUPP;
  163.  
  164. extern long GetDblTime( void )
  165.     TWOWORDINLINE( 0x2038, 0x02F0 ); /* MOVE.L $02F0, D0 */
  166. extern long GetCaretTime( void )
  167.     TWOWORDINLINE( 0x2038, 0x02F4 ); /* MOVE.L $02F4, D0 */
  168. extern void SetEventMask( short value )
  169.     TWOWORDINLINE( 0x31D7, 0x0144 ); /* MOVE.W (SP),$0144 */
  170. extern pascal QHdrPtr GetEventQueue(void)
  171.  THREEWORDINLINE(0x2EBC, 0x0000, 0x014A);
  172. extern pascal Boolean GetNextEvent(short eventMask, EventRecord *theEvent)
  173.  ONEWORDINLINE(0xA970);
  174. extern pascal Boolean WaitNextEvent(short eventMask, EventRecord *theEvent, unsigned long sleep, RgnHandle mouseRgn)
  175.  ONEWORDINLINE(0xA860);
  176. extern pascal Boolean EventAvail(short eventMask, EventRecord *theEvent)
  177.  ONEWORDINLINE(0xA971);
  178. extern pascal void GetMouse(Point *mouseLoc)
  179.  ONEWORDINLINE(0xA972);
  180. extern pascal Boolean Button(void)
  181.  ONEWORDINLINE(0xA974);
  182. extern pascal Boolean StillDown(void)
  183.  ONEWORDINLINE(0xA973);
  184. extern pascal Boolean WaitMouseUp(void)
  185.  ONEWORDINLINE(0xA977);
  186. extern pascal void GetKeys(KeyMap theKeys)
  187.  ONEWORDINLINE(0xA976);
  188. extern pascal long KeyTranslate(const void *transData, short keycode, long *state)
  189.  ONEWORDINLINE(0xA9C3);
  190. extern pascal unsigned long TickCount(void)
  191.  ONEWORDINLINE(0xA975);
  192.  
  193. #if !GENERATINGCFM
  194. #pragma parameter __D0 PostEvent(__A0, __D0)
  195. #endif
  196. extern pascal OSErr PostEvent(short eventNum, long eventMsg)
  197.  ONEWORDINLINE(0xA02F);
  198.  
  199. #if !GENERATINGCFM
  200. #pragma parameter __D0 PPostEvent(__A0, __D0, __A1)
  201. #endif
  202. extern pascal OSErr PPostEvent(short eventCode, long eventMsg, EvQElPtr *qEl)
  203.  TWOWORDINLINE(0xA12F, 0x2288);
  204.  
  205. #if !GENERATINGCFM
  206. #pragma parameter __D0 OSEventAvail(__D0, __A0)
  207. #endif
  208. extern pascal Boolean OSEventAvail(short mask, EventRecord *theEvent)
  209.  TWOWORDINLINE(0xA030, 0x5240);
  210.  
  211. #if !GENERATINGCFM
  212. #pragma parameter __D0 GetOSEvent(__D0, __A0)
  213. #endif
  214. extern pascal Boolean GetOSEvent(short mask, EventRecord *theEvent)
  215.  TWOWORDINLINE(0xA031, 0x5240);
  216. extern pascal void FlushEvents(short whichMask, short stopMask)
  217.  TWOWORDINLINE(0x201F, 0xA032);
  218. extern pascal void SystemClick(const EventRecord *theEvent, WindowPtr theWindow)
  219.  ONEWORDINLINE(0xA9B3);
  220. extern pascal void SystemTask(void)
  221.  ONEWORDINLINE(0xA9B4);
  222. extern pascal Boolean SystemEvent(const EventRecord *theEvent)
  223.  ONEWORDINLINE(0xA9B2);
  224. #if OLDROUTINENAMES
  225. #define KeyTrans(transData, keycode, state) KeyTranslate(transData, keycode, state)
  226. #define GetEvQHdr() GetEventQueue()
  227. #endif
  228.  
  229. #ifdef __CFM68K__
  230. #pragma lib_export off
  231. #endif
  232.  
  233. #if GENERATINGPOWERPC
  234. #pragma options align=reset
  235. #endif
  236.  
  237. #ifdef __cplusplus
  238. }
  239. #endif
  240.  
  241. #endif /* __EVENTS__ */
  242.